package fraction;

import java.util.Scanner;
import java.util.InputMismatchException;

/**
 * Class Main
 *
 * @author lorenz gorse
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        MixedFraction f1, f2;
		try {
			while(true) {
				System.out.println("Bruch 1");
				System.out.print("Zähler: ");
				int numerator = s.nextInt();
				System.out.print("Nenner: ");
				int denominator = s.nextInt();
				f1 = new MixedFraction(numerator, denominator);

				System.out.println("Bruch 2");
				System.out.print("Zähler: ");
				numerator = s.nextInt();
				System.out.print("Nenner: ");
				denominator = s.nextInt();

				f2 = new MixedFraction(numerator, denominator);

				if(MixedFraction.isEqual(f1, f2)) {
					System.out.println("Die Brüche sind gleich!");
				}

				System.out.println("f1 + f2 = " + MixedFraction.add(f1, f2).toString());
				System.out.println("f1 - f2 = " + MixedFraction.subtract(f1, f2).toString());
				System.out.println("f1 * f2 = " + MixedFraction.multiplicate(f1, f2).toString());
				System.out.println("f1 / f2 = " + MixedFraction.divide(f1, f2).toString());
			}
		} catch (InputMismatchException e) {
			System.err.println("Programm wird beendet");
		}
    }
}
